package com.ruoyi.bizsys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.bizsys.domain.AwardGroup;
import com.ruoyi.bizsys.mapper.AwardGroupMapper;
import com.ruoyi.bizsys.service.IAwardGroupService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;


/**
 * 奖励分组Service业务层处理
 *
 * @author african-loan
 * @date 2022-06-22
 */
@Service
public class AwardGroupServiceImpl extends ServiceImpl<AwardGroupMapper,AwardGroup> implements IAwardGroupService {

    /**
     * 查询奖励分组
     *
     * @param id 奖励分组ID
     * @return 奖励分组
     */
    @Override
    public AwardGroup selectAwardGroupById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询奖励分组列表
     *
     * @param awardGroup 奖励分组
     * @return 奖励分组
     */
    @Override
    public List<AwardGroup> selectAwardGroupList(AwardGroup awardGroup) {
        return this.list(new QueryWrapper<>(awardGroup).last("order by id desc"));
    }

    /**
     * 新增奖励分组
     *
     * @param awardGroup 奖励分组
     * @return 结果
     */
            @Override
    public int insertAwardGroup(AwardGroup awardGroup) {
                                                                                                                    awardGroup.setCreateTime(DateUtils.getNowDate());
                            return baseMapper.insert(awardGroup);
    }

    /**
     * 修改奖励分组
     *
     * @param awardGroup 奖励分组
     * @return 结果
     */
            @Override
    public int updateAwardGroup(AwardGroup awardGroup) {
                                                                                                                    return baseMapper.updateById(awardGroup);
    }

    /**
     * 批量删除奖励分组
     *
     * @param ids 需要删除的奖励分组ID
     * @return 结果
     */
            @Override
    public int deleteAwardGroupByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除奖励分组信息
     *
     * @param id 奖励分组ID
     * @return 结果
     */
    @Override
    public int deleteAwardGroupById(Long id) {
        return baseMapper.deleteById(id);
    }

}
